package reflect;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

public class ReflectDemo3 {
    public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException {
        Person p1 = new Person();
        System.out.println(p1);

        Person p2 = new Person("李四",25);
        System.out.println(p2);

        Class cls = Class.forName("reflect.Penson");

        Constructor c =cls.getConstructor(String.class,int.class);
        Object obj = c.newInstance("王五",33);
        System.out.println(obj);

    }
}
